package TestStudentComparator;
import charpter20.StudentClass;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class TestStudentComparator {
    public static void main(String[] args) {
        StudentClass c1 =new StudentClass(20200313,"yang", 60);
        StudentClass c2 =new StudentClass(20200314,"wang", 70);
        StudentClass c3 =new StudentClass(20200315,"ling", 90);
//        List<StudentClass> studentClassList = Arrays.asList(c1.score,c2.score,c3.score);
        List<StudentClass> studentClassList=new ArrayList<>();
        studentClassList.add(c1);
        studentClassList.add(c2);
        studentClassList.add(c3);
        Collections.sort(studentClassList,new StudentClassComparator());
        Collections.reverse(studentClassList);
        System.out.println("降序排序：");
        for (StudentClass s:studentClassList){
            System.out.println(s);
        }
        System.out.println("最大值："+Collections.max(studentClassList, new StudentClassComparator()));
        System.out.println("最小值："+Collections.min(studentClassList, new StudentClassComparator()));
    }

}
